package com.bmslz.monitor.base.vo;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.util.List;

/**
 * @Description: 监控模型att
 * @Author: bobo
 * @Date: 2025-08-23
 * @Version: V1.0
 */
@Data
public class MonitorAttVo {
    //[{"attName":"cpu","attKey":"cpu","attType":"1","remakes":"备注"}]
    private List<Item> attList;

    @Data
    public static class Item {
        private String attName;//测点名称
        private String attKey;//测点key
        private String attType;//测点type
        private String remakes;//备注
    }

    // 添加这个方法来兼容数组格式的JSON
    public static List<Item> parseArrayJson(String json) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, Item.class));
    }
}
